#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const int maxn = 2000000 + 1;

/**
 * 欧拉函数的计算 定义法
 * @param n
 * @return
 */
int phi(int n) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (__gcd(i, n) == 1)
            ++ans;
    }
    return ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;

    cout << phi(n) << endl;
    return 0;
}
